// eslint-disable-next-line
import { UserLayout, BasicLayout, BlankLayout } from '@/layouts'

const RouteView = {
  name: 'RouteView',
  render: h => h('router-view')
}

export const asyncRouterMap = [
  {
    path: '/',
    name: 'index',
    component: BasicLayout,
    meta: { title: '首页' },
    redirect: '/product',
    children: [
      // 产品管理
      {
        path: '/product',
        name: 'product',
        component: RouteView,
        meta: { title: '产品管理', icon: 'slack', keepAlive: true },
        redirect: '/product/course',
        children: [
          {
            path: 'course',
            name: 'productCourse',
            component: () => import('@/views/product/course'),
            meta: { title: '课程管理', icon: 'tool', keepAlive: true }
          },
          {
            path: 'course-common',
            name: 'productCourseCommon',
            hidden: true,
            component: () => import('@/views/product/courseCommon'),
            meta: { title: '课程管理', icon: 'tool', keepAlive: true }
          },
          {
            path: 'copy-course',
            name: 'productCopyCourse',
            hidden: true,
            component: () => import('@/views/product/copyCourseWare'),
            meta: { title: '课程管理', icon: 'tool', keepAlive: true }
          },
          {
            path: 'learning',
            name: 'productLearning',
            component: () => import('@/views/product/learning'),
            meta: { title: '学习包管理', icon: 'tool', keepAlive: true }
          },
          {
            path: 'learning-common',
            name: 'productLearningCommon',
            hidden: true,
            component: () => import('@/views/product/learningCommon'),
            meta: { title: '学习包管理', icon: 'tool', keepAlive: true }
          },
          {
            path: 'learning-view',
            name: 'productLearningView',
            hidden: true,
            component: () => import('@/views/product/learningView'),
            meta: { title: '学习包管理', icon: 'tool', keepAlive: true }
          },
          {
            path: 'serve',
            name: 'productServe',
            component: () => import('@/views/product/serve'),
            meta: { title: '课程服务管理', icon: 'tool', keepAlive: true }
          },
          {
            path: 'goods',
            name: 'productGoods',
            component: () => import('@/views/product/goods'),
            meta: { title: '商品管理', icon: 'tool', keepAlive: true }
          },
          {
            path: 'goods-app',
            name: 'productGoodsApp',
            hidden: true,
            component: () => import('@/views/product/appContentManagement'),
            meta: { title: '商品管理', icon: 'tool', keepAlive: true }
          },
          {
            path: 'goods-agree',
            name: 'productGoodsAgree',
            hidden: true,
            component: () => import('@/views/product/relevanceAgree'),
            meta: { title: '商品管理', icon: 'tool', keepAlive: true }
          },
          {
            path: 'goods-common',
            name: 'productGoodsCommon',
            hidden: true,
            component: () => import('@/views/product/goodsCommon'),
            meta: { title: '商品管理', icon: 'tool', keepAlive: true }
          }
        ]
      },
      // 考试管理
      {
        path: '/examination',
        name: 'examination',
        component: RouteView,
        meta: { title: '考试管理', icon: 'slack', keepAlive: true },
        redirect: '/examination/exam',
        children: [
          {
            path: 'exam',
            name: 'exam',
            component: () => import('@/views/examination/exam'),
            meta: { title: '考试管理', icon: 'tool', keepAlive: true }
          },
          {
            path: 'exam-common',
            name: 'examCommon',
            hidden: true,
            component: () => import('@/views/examination/examCommon'),
            meta: { title: '考试管理', icon: 'tool', keepAlive: true }
          },
          {
            path: 'preset',
            name: 'preset',
            component: () => import('@/views/examination/preset'),
            meta: { title: '考试预设管理', icon: 'tool', keepAlive: true }
          },
          {
            path: 'preset-common',
            name: 'presetCommon',
            hidden: true,
            component: () => import('@/views/examination/presetCommon'),
            meta: { title: '考试预设管理', icon: 'tool', keepAlive: true }
          }
        ]
      },
      // 协议管理
      {
        path: '/agreement',
        name: 'agreement',
        component: RouteView,
        meta: { title: '协议管理', icon: 'slack', keepAlive: true },
        redirect: '/agreement/clause',
        children: [
          {
            path: 'clause',
            name: 'clause',
            component: () => import('@/views/agreement/clause'),
            meta: { title: '协议条款管理', icon: 'tool', keepAlive: true }
          },
          {
            path: 'clause-common',
            name: 'clauseCommon',
            hidden: true,
            component: () => import('@/views/agreement/clauseCommon'),
            meta: { title: '协议条款管理', icon: 'tool', keepAlive: true }
          },
          {
            path: 'template',
            name: 'template',
            component: () => import('@/views/agreement/templatea'),
            meta: { title: '协议模板管理', icon: 'tool', keepAlive: true }
          },
          {
            path: 'templatea-common',
            name: 'templateaCommon',
            hidden: true,
            component: () => import('@/views/agreement/templateaCommon'),
            meta: { title: '协议模板管理', icon: 'tool', keepAlive: true }
          },
          {
            path: 'management',
            name: 'management',
            component: () => import('@/views/agreement/management'),
            meta: { title: '协议管理', icon: 'tool', keepAlive: true }
          },
          {
            path: 'add-agree',
            name: 'agree',
            hidden: true,
            component: () => import('@/views/agreement/agree'),
            meta: { title: '协议管理', icon: 'tool', keepAlive: true }
          }
        ]
      },
      // Exception
      {
        path: '/exception',
        name: 'exception',
        component: RouteView,
        redirect: '/exception/403',
        hidden: true,
        meta: { title: 'menu.exception', icon: 'warning', permission: ['exception'] },
        children: [
          {
            path: '/exception/403',
            name: 'Exception403',
            component: () => import(/* webpackChunkName: "fail" */ '@/views/exception/403'),
            meta: { title: 'menu.exception.not-permission', permission: ['exception'] }
          },
          {
            path: '/exception/404',
            name: 'Exception404',
            component: () => import(/* webpackChunkName: "fail" */ '@/views/exception/404'),
            meta: { title: 'menu.exception.not-find', permission: ['exception'] }
          },
          {
            path: '/exception/500',
            name: 'Exception500',
            component: () => import(/* webpackChunkName: "fail" */ '@/views/exception/500'),
            meta: { title: 'menu.exception.server-error', permission: ['exception'] }
          }
        ]
      }
    ]
  },
  {
    path: '*',
    redirect: '/404',
    hidden: true
  }
]

/**
 * 基础路由
 * @type { *[] }
 */
export const constantRouterMap = [
  {
    path: '/user',
    component: UserLayout,
    redirect: '/user/login',
    hidden: true,
    children: [
      {
        path: 'login',
        name: 'login',
        component: () => import(/* webpackChunkName: "user" */ '@/views/user/Login')
      }
    ]
  },
  {
    path: '/404',
    component: () => import(/* webpackChunkName: "fail" */ '@/views/exception/404')
  }
]
